package com.hcc.repository.gen.constants;

import com.hcc.repository.core.utils.CollUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * DefaultTemplatePath
 *
 * @author hushengjun
 * @date 2023/9/28
 */
public class TemplatePathConstants {

    private static final Map<TemplateEngineType, Map<String, String>> engineTypeTemplatePathMap = new HashMap<>();

    static {
        engineTypeTemplatePathMap.put(TemplateEngineType.FREEMARKER, new HashMap<String, String>() {{
            put(GenerateTypeConstants.ENTITY, "templates/freemarker/entity.ftl");
            put(GenerateTypeConstants.MAPPER, "templates/freemarker/mapper.ftl");
            put(GenerateTypeConstants.REPOSITORY, "templates/freemarker/repository.ftl");
            put(GenerateTypeConstants.REPOSITORY_IMPL, "templates/freemarker/repositoryImpl.ftl");
            put(GenerateTypeConstants.SERVICE, "templates/freemarker/service.ftl");
            put(GenerateTypeConstants.SERVICE_IMPL, "templates/freemarker/serviceImpl.ftl");
            put(GenerateTypeConstants.CONTROLLER, "templates/freemarker/controller.ftl");
        }});
        engineTypeTemplatePathMap.put(TemplateEngineType.VELOCITY, new HashMap<String, String>() {{
            put(GenerateTypeConstants.ENTITY, "templates/velocity/entity.vm");
            put(GenerateTypeConstants.MAPPER, "templates/velocity/mapper.vm");
            put(GenerateTypeConstants.REPOSITORY, "templates/velocity/repository.vm");
            put(GenerateTypeConstants.REPOSITORY_IMPL, "templates/velocity/repositoryImpl.vm");
            put(GenerateTypeConstants.SERVICE, "templates/velocity/service.vm");
            put(GenerateTypeConstants.SERVICE_IMPL, "templates/velocity/serviceImpl.vm");
            put(GenerateTypeConstants.CONTROLLER, "templates/velocity/controller.vm");
        }});
    }

    public static String getDefaultTemplatePath(TemplateEngineType engineType, String generateType) {
        Map<String, String> generateTypeMap = engineTypeTemplatePathMap.get(engineType);
        if (CollUtils.isEmpty(generateTypeMap)) {
            return null;
        }
        return generateTypeMap.get(generateType);
    }

}
